package QC.MessageBox.beans.wxmsg.normalmsg;

import io.vertx.core.json.JsonObject;

/**
 * Created by Andaren on 2017/6/5.
 * Used for: 根据标签进行群发【订阅号与服务号认证后均可用】
 */
public class WXGroupSendMsgByTag {

    private boolean is_to_all;              // 用于设定是否向全部用户发送，值为true或false，选择true该消息群发给所有用户，选择false可根据tag_id发送给指定群组的用户

    private String tag_id;                  // 群发到的标签的tag_id，参加用户管理中用户分组接口，若is_to_all值为true，可不填写tag_id

    private String media_id;                // 用于群发的消息的media_id

    private String msgtype;                 // 群发的消息类型，图文消息为mpnews，文本消息为text，语音为voice，音乐为music，图片为image，视频为video，卡券为wxcard

    private Integer send_ignore_reprint;     // 1为继续群发（转载），0为停止群发。

    public boolean isIs_to_all() {
        return is_to_all;
    }

    public WXGroupSendMsgByTag setIs_to_all(boolean is_to_all) {
        this.is_to_all = is_to_all;
        return this;
    }

    public String getTag_id() {
        return tag_id;
    }

    public WXGroupSendMsgByTag setTag_id(String tag_id) {
        this.tag_id = tag_id;
        return this;
    }

    public String getMedia_id() {
        return media_id;
    }

    public WXGroupSendMsgByTag setMedia_id(String media_id) {
        this.media_id = media_id;
        return this;
    }

    public String getMsgtype() {
        return msgtype;
    }

    public WXGroupSendMsgByTag setMsgtype(String msgtype) {
        this.msgtype = msgtype;
        return this;
    }

    public Integer getSend_ignore_reprint() {
        return send_ignore_reprint;
    }

    public WXGroupSendMsgByTag setSend_ignore_reprint(Integer send_ignore_reprint) {
        this.send_ignore_reprint = send_ignore_reprint;
        return this;
    }

    public JsonObject toJson() {
        JsonObject msg = new JsonObject();
        JsonObject filterJson = new JsonObject()
                .put("is_to_all", is_to_all);
        if (!is_to_all) {
            filterJson.put("tag_id", tag_id);
        }
        JsonObject mpNewsJson = new JsonObject()
                .put("media_id", media_id);
        //
        msg
                .put("filter", filterJson)
                .put("mpnews", mpNewsJson)
                .put("msgtype", "mpnews")
                .put("send_ignore_reprint", send_ignore_reprint);
        return msg;
    }
}
